package com.android.widget.horizontallistview;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.android.widget.demo.R;

public class HorizontalListViewDemo extends Activity {

    private List<String> mData;
    
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.activity_horizontal_listview);
		
		initData();
		HorizontalListView listview = (HorizontalListView) findViewById(R.id.listview);
		listview.setAdapter(mAdapter);
		
	}
	
	private  void initData() {
	    mData = new ArrayList<String>();
	    
	    for(int i = 0;i<30000;i++) {
	        mData.add("Linc #"+i);
	    }
	}
	private static String[] dataObjects = new String[]{ 
	    "Text #1",
		"Text #2",
		"Text #3",
		"Linc #4",
		"Linc #5",
		"Linc #6",
		"Linc #7",
		"Linc #8",
		"Linc #9" }; 
	
	private BaseAdapter mAdapter = new BaseAdapter() {

		@Override
		public int getCount() {
			//return dataObjects.length;
		    return mData.size();
		}

		@Override
		public Object getItem(int position) {
			return null;
		}

		@Override
		public long getItemId(int position) {
			return 0;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			View retval = LayoutInflater.from(parent.getContext()).inflate(R.layout.horizontal_listview_item, null);
			TextView title = (TextView) retval.findViewById(R.id.title);
			title.setText(mData.get(position));
			
			return retval;
		}
		
	};

}
